package searchandsort;

import java.util.PriorityQueue;
//todo use k-sort
public class KthSmallestPrimeFraction786 {
    public int[] kthSmallestPrimeFraction(int[] arr, int k) {
        PriorityQueue<int[]> queue = new PriorityQueue((o1, o2) -> {
            int[] oo1 = (int[]) o1;
            int[] oo2 = (int[]) o2;
            return (oo1[0] * oo2[1])- (oo1[1] * oo2[0]) ;
        });

        for (int i = arr.length - 1; i >= 0; i--) {
            for (int j = 0; j < i; j++) {
                queue.add(new int[]{arr[j], arr[i]});
            }
        }
        for (int i = 1; i < k; i++) {
            queue.poll();
        }
        return queue.poll();
    }

}
